package com.hyfrogx.modules.push.notification;

import cn.hutool.core.util.ObjectUtil;
import com.hyfrogx.modules.push.config.UmConfig;
import com.hyfrogx.modules.push.util.UmPushUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;


@Slf4j
@Data
public class UmAndriodNotification extends UmNotification{

    public UmAndriodNotification(String type, Map params){
        super(type,params);
        this.setSys(UmConfig.Sys.Android.name());
        this.setAppMasterSecret(UmConfig.AppMasterSecret);
        if(ObjectUtil.isEmpty(UmConfig.AppKey)){
            this.getParams().put("appkey","59e4412245297d3990000027");
            this.setAppMasterSecret("xcsxwvvpk1qmdivigs4hrhr0wu9ak9bi");
        }else {
            this.getParams().put("appkey",UmConfig.AppKey);
        }
        UmPushUtil.setAndriodBody(this.getParams());
        //必填参数验证
        this.setBody(this.getParams());
        UmPushUtil.checkBaseParam(this.getBody());
    }

    public void setDisplayType(String displayType){
        Map content=this.getBody();
        UmPushUtil.setAndriodKeyValue(content,"display_type",displayType);
    }

    public void setKeyValue(String key,Object value){
        Map content=this.getBody();
        UmPushUtil.setAndriodKeyValue(content,key,value);
    }
}
